package com.example.nio;

import java.io.IOException;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

    public class OkHttpDemo {
        final OkHttpClient client = new OkHttpClient();

        String run(String url) throws IOException {
            Request request = new Request.Builder()
                    .url(url)
                    .build();

            try (Response response = client.newCall(request).execute()) {
                return response.body().string();
            }
        }

        public static void main(String[] args) throws IOException {
            OkHttpDemo example = new OkHttpDemo();
            String response = example.run("http://localhost:8801");
            System.out.println(response);
        }
    }
